//
//  ExpressInforTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/7.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "ExpressInforTableViewCell.h"

@interface ExpressInforTableViewCell ()

@property (nonatomic,strong) GLGWImageView * leftimageView;

@property (nonatomic,strong) GLGWView * topLineView;

@property (nonatomic,strong) GLGWView * bottomLineView;

@property (nonatomic,strong) GLGWLabel * timeLabel;

@property (nonatomic, strong) GLGWLabel *topLabel;
@end

@implementation ExpressInforTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.leftimageView = [[GLGWImageView alloc] initWithImageName:@"kk" inSuperView:self.contentView];
        [self.leftimageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(@(kHeightProportion_In_iPhoneTriploid(30)));
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(20)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        
        self.topLineView = [[GLGWView alloc] initWithInSuperView:self.contentView];
        self.topLineView.backgroundColor = [UIColor colorWithHexString:@"#DEDEDE"];;
        [self.topLineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@(kWidthProportion_In_iPhoneTriploid(24)));
            make.top.equalTo(self.contentView);
            make.bottom.equalTo(self.leftimageView.mas_top);
            make.width.equalTo(@1);
        }];

        self.bottomLineView = [[GLGWView alloc] initWithInSuperView:self.contentView];
        self.bottomLineView.backgroundColor = [UIColor colorWithHexString:@"#DEDEDE"];;
        [self.bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.topLineView.mas_left);
            make.top.equalTo(self.leftimageView.mas_bottom);
            make.bottom.equalTo(self.contentView);
            make.width.equalTo(@1);
        }];
        
        GLGWLabel *topLab = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:kColor_Rule_Black inSuperView:self.contentView];
        [topLab mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
            make.left.equalTo(self.leftimageView.mas_right).offset(kWidthProportion_In_iPhoneTriploid(20));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(18));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(24));
        }];
        topLab.text = @"您的订单已由火车运输，车牌/车次为京A12311,司机姓名为黎明，18000000000，请耐心等待！";
        topLab.numberOfLines = 0;
        self.topLabel = topLab;
        
        self.timeLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:self.contentView];
        self.timeLabel.text = @"2018-07-31 12:23:23";
        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(topLab.mas_left);
            make.bottom.equalTo(self.contentView);
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
    }
    return self;
}

- (void)refreshExpressInforTableViewCell:(ExpressInforModel *)model index:(NSIndexPath *)index
{
    ExpressInforDataModel *dataModel = model.data[index.row];
    self.topLabel.text = dataModel.remark;
    self.timeLabel.text = dataModel.createTime;
    self.leftimageView.image = [UIImage imageNamed:@"icon_weixuanzhejindu"];

    NSInteger cou = model.data.count - 1;
    if (index.row == 0) {
        self.topLineView.backgroundColor = [UIColor whiteColor];
        self.leftimageView.image = [UIImage imageNamed:@"icon_shengcheng"]; // 选中
        self.bottomLineView.backgroundColor = [UIColor colorWithHexString:@"#DEDEDE"];

        if (cou == 0) {
            self.bottomLineView.backgroundColor = [UIColor whiteColor];
        }
    } else if (index.row == cou) {
        self.bottomLineView.backgroundColor = [UIColor whiteColor];
    }

}

@end
